//
//  OrderDetailView.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/26.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "CommonDetailView.h"
#import "GoodsView.h"
#import "DeleteNull.h"
@interface CommonDetailView()
@property(nonatomic,strong)UIView*orderView;

@property(nonatomic,strong)UIView*sendView;
@property(nonatomic,strong)UIView*noView;
@property(nonatomic,strong)UIView*memberView;
@property(nonatomic,strong)UILabel*stateLabel;
//@property(nonatomic,strong)UILabel*stateLabel1;

@property(nonatomic,strong)UILabel*orderNoLabel;
@property(nonatomic,strong)UILabel*source;
@property(nonatomic,strong)UILabel*sourceLabel;
@property(nonatomic,strong)UILabel*orderDate;
@property(nonatomic,strong)UILabel*orderDateLabel;
@property(nonatomic,strong)UILabel*memberName;
@property(nonatomic,strong)UILabel*memberNameLabel;
@property(nonatomic,strong)UILabel*address;
@property(nonatomic,strong)UILabel*addressLabel;
@property(nonatomic,strong)UIImageView*sexImage;
@property(nonatomic,strong)UILabel*consignee;
@property(nonatomic,strong)UILabel*consigneeLabel;
@property(nonatomic,strong)UILabel*levelLabel;
@property(nonatomic,strong)UILabel*level;
@property(nonatomic,strong)UIView*orderItemView;
@property(nonatomic,strong)UIButton*jiantouBtn;

@property(nonatomic,strong)UILabel*takeExpiryDate;
@property(nonatomic,strong)UILabel*takeExpiryDateLabel;
@property(nonatomic,strong)UILabel*sendInfo;
@property(nonatomic,strong)UILabel*send;
@property(nonatomic,strong)UILabel*freight;
@property(nonatomic,strong)UILabel*sendLabel;
@property(nonatomic,strong)UILabel*freightLabel;
@end
@implementation CommonDetailView
{
NSString*hight;
GoodsView*goodsView;
  int hight1;
NSMutableArray*orderItemArray;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    
        
    }
    return self;
}
#pragma mark InitUI
- (void)initUI
{
    self .backgroundColor = [UIColor whiteColor];
    _orderView=[[UIView alloc]init];
    _orderView.backgroundColor=[UIColor whiteColor];
    [self addSubview:_orderView];
    
    _noView=[[UIView alloc]init];
    _noView.backgroundColor=[UIColor whiteColor];
    [_orderView addSubview:_noView];
   
    _memberView=[[UIView alloc]init];
    _memberView.backgroundColor=[UIColor whiteColor];
    [_orderView addSubview:_memberView];
   
    _sendView=[[UIView alloc]init];
    _sendView.backgroundColor=[UIColor whiteColor];
    [_orderView addSubview:_sendView];
    _orderNoLabel=[[UILabel alloc]init];
    _orderNoLabel.textColor=[UIColor blackColor];
    _orderNoLabel.font=[UIFont systemFontOfSize:17];
    [self addSubview:_orderNoLabel];
    
    
    _stateLabel=[[UILabel alloc]init];
    _stateLabel.textColor=luseColor;
    _stateLabel.textAlignment=NSTextAlignmentCenter;
    _stateLabel.font=[UIFont systemFontOfSize:Statusfot];
    [self addSubview:_stateLabel];
    
    
    _stateLabel1=[[UILabel alloc]init];
    _stateLabel1.textColor=luseColor;
    _stateLabel1.font=[UIFont systemFontOfSize:Statusfot];
    [self addSubview:_stateLabel1];

    _stateLabel2=[[UILabel alloc]init];
    _stateLabel2.textColor=luseColor;
    _stateLabel2.font=[UIFont systemFontOfSize:Statusfot];
    [self addSubview:_stateLabel2];

    
    _source=[[UILabel alloc]init];
    _source.text=[NSString stringWithFormat:@"来源"];
    _source.textColor=zhonghuiColor;
    _source.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_source];
    
    _sourceLabel=[[UILabel alloc]init];
    _sourceLabel.textColor=shenhuiColor;
    _sourceLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_sourceLabel];
    
    _orderDateLabel=[[UILabel alloc]init];
    _orderDateLabel.textColor=zhonghuiColor;
    _orderDateLabel.text=[NSString stringWithFormat:@"日期"];
    _orderDateLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_orderDateLabel];
    _orderDate=[[UILabel alloc]init];
    _orderDate.textColor=shenhuiColor;
    _orderDate.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_orderDate];
  
    _memberName=[[UILabel alloc]init];
    _memberName.textColor=qianheiColor;
    _memberName.font=[UIFont systemFontOfSize:16];
    [self addSubview:_memberName];

    _sexImage=[[UIImageView alloc]init];
    [self addSubview:_sexImage];

    _level=[[UILabel alloc]init];
    _level.textColor=zhonghuiColor;
    _level.text=@"等级";
    _level.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_level];

    _levelLabel=[[UILabel alloc]init];
    [_levelLabel.layer setCornerRadius:1.5];
    [_levelLabel.layer setBorderWidth:0];
    [_levelLabel.layer setMasksToBounds:YES];
    _levelLabel.textColor=[UIColor whiteColor];
    _levelLabel.font=[UIFont systemFontOfSize:13];
    [self addSubview:_levelLabel];
    _jiantouBtn=[[UIButton alloc]init];
    [_jiantouBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
    [_jiantouBtn addTarget:self action:@selector(jiantouBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_jiantouBtn];


    
    _sendInfo=[[UILabel alloc]init];
    _sendInfo.textColor=qianheiColor;
    _sendInfo.text=@"配送信息";
    _sendInfo.font=[UIFont systemFontOfSize:15];
    [self addSubview:_sendInfo];
    
    _send=[[UILabel alloc]init];
    _send.textColor=shenhuiColor;
    _send.text=@"配送方式";
    _send.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_send];
    _sendLabel=[[UILabel alloc]init];
    _sendLabel.textColor=qianheiColor;
    _sendLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_sendLabel];
    _freight=[[UILabel alloc]init];
    _freight.textColor=shenhuiColor;
    _freight.text=@"运费";
    _freight.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_freight];
    _freightLabel=[[UILabel alloc]init];
    _freightLabel.textColor=qianheiColor;
    _freightLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_freightLabel];
    
    
    
    _takeExpiryDate=[[UILabel alloc]init];
    _takeExpiryDate.textColor=shenhuiColor;
    _takeExpiryDate.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_takeExpiryDate];
    _takeExpiryDateLabel=[[UILabel alloc]init];
    _takeExpiryDateLabel.textColor=qianheiColor;
    _takeExpiryDateLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_takeExpiryDateLabel];
    
    _consignee=[[UILabel alloc]init];
    _consignee.textColor=shenhuiColor;
    _consignee.text=@"收货人";
    _consignee.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_consignee];
    _consigneeLabel=[[UILabel alloc]init];
    _consigneeLabel.textColor=qianheiColor;
    _consigneeLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_consigneeLabel];

    _address=[[UILabel alloc]init];
    _address.textColor=shenhuiColor;
    _address.text=@"收货地址";
    _address.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_address];
    
    _addressLabel=[[UILabel alloc]init];
    _addressLabel.textAlignment=NSTextAlignmentRight;
    _addressLabel.textColor=qianheiColor;
    _addressLabel.numberOfLines=0;
    _addressLabel.font=[UIFont systemFontOfSize:contenfot];
    [self addSubview:_addressLabel];

    _orderItemView=[[UIView alloc]init];
    _orderItemView.backgroundColor=[UIColor whiteColor];
    [self addSubview:_orderItemView];

    UIImageView *_xianview = [[UIImageView alloc]initWithFrame:CGRectMake(10,130, ScreenWidth-20, 0.5)];
    _xianview.image=[UIImage imageNamed:@"hengxian"];
    [self addSubview:_xianview];
    
    
    UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
    shangpingxinxi.text=@"商品信息";
    shangpingxinxi.textColor=qianheiColor;
    shangpingxinxi.font=[UIFont systemFontOfSize:15];
    [_orderItemView addSubview:shangpingxinxi];
    
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 45-0.40, ScreenWidth-20, 0.40)];
    lineLabel.backgroundColor=qianhuiColor;
    [_orderItemView addSubview:lineLabel];
    
    
    UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 70, ScreenWidth, 10)];
    view.backgroundColor=zuiqianhuiColor;
    view.layer.borderColor = qianhuiColor.CGColor;
    [view.layer setBorderWidth:0.40];   //边
    [self addSubview:view];
    UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0, 80+45, ScreenWidth, 10)];
    view1.backgroundColor=zuiqianhuiColor;
    view1.layer.borderColor = qianhuiColor.CGColor;
    [view1.layer setBorderWidth:0.40];   //边
    [self addSubview:view1];
    
    UIView*view2=[[UIView alloc]initWithFrame:CGRectMake(0, hight1-10, ScreenWidth, 10)];
    view2.backgroundColor=zuiqianhuiColor;
    view2.layer.borderColor = qianhuiColor.CGColor;
    [view2.layer setBorderWidth:0.40];   //边
    [self addSubview:view2];
    
    _heightView=[[UIView alloc]init];
    _heightView.backgroundColor=qianhuiColor;
    [self addSubview:_heightView];
}

-(void)jiantouBtn:(UIButton*)sender{

    [_mDelegate memberBtn:@""];
}
-(void)setModel:(OrderDetailModel *)model{
    if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"deliveryType"]]isEqualToString:@"shsm"]) {
        hight1=310;
        }else{
        if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
            hight1=330;
            
        }else{
            
           hight1=310;
        }
        
    }

    [self initUI];
    [self setViewAutoLayout:model.dict];
    _orderDateLabel.text=[NSString stringWithFormat:@"下单时间"];
    self.orderNoLabel.text=[NSString stringWithFormat:@"%@", [[model.dict objectForKey:@"order"] objectForKey:@"orderNo"]];
    
    model.dict=[DeleteNull changeType:model.dict];
    if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=orangeCol;
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.text=[NSString stringWithFormat:@"%@", @"预售 "];
    }else  if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Retail"]){
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=luseColor;
        self.stateLabel.text=[NSString stringWithFormat:@"%@", @"零售 "];
    }else  if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Wx"]){
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=orangeCol;
        self.stateLabel.text=[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docTypeName"]]];
    }else  if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Integral"]){
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=orangeCol;
        self.stateLabel.text=[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docTypeName"]]];
    }

    

    
if ([[NSString stringWithFormat:@"%@",   [[model.dict objectForKey:@"order"] objectForKey:@"payStatusName"]]isEqualToString:@"已收银"]) {
        self.stateLabel1.textColor=luseColor;
    }else{
        self.stateLabel1.textColor=shenhongseColor;
    }
    if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]]isEqualToString:@"已完成"]) {
        self.stateLabel2.textColor=luseColor;
    }else if([[NSString stringWithFormat:@"%@", [[model.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]]isEqualToString:@"已取消"]){
        self.stateLabel2.textColor=shenhuiColor;
        
    }else{
        self.stateLabel2.textColor=shenhongseColor;
        
    }

    self.stateLabel1.text=[NSString stringWithFormat:@"%@",   [[model.dict objectForKey:@"order"] objectForKey:@"payStatusName"]];
    self.stateLabel2.text=[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"source"]];
    
    NSString* string =[[model.dict objectForKey:@"order"] objectForKey:@"orderDate"] ;
    self.orderDate.text=[NSString stringWithFormat:@"%@",   string];
   
    NSDictionary *value = [model.dict objectForKey:@"member"];
     NSLog(@"---%ld",value.count);
    if (value.count==0)
    {
        self.memberName.text=@"零售会员";
        self.sexImage.image=[UIImage imageNamed:@""];
        _level.text=@"";
        _levelLabel.backgroundColor=[UIColor clearColor];
        _levelLabel.text=@"";
        [_jiantouBtn removeFromSuperview];
        
    }
    else
    {
        self.memberName.text=[NSString stringWithFormat:@"%@ (%@)",[[model.dict objectForKey:@"member"] objectForKey:@"memberName"], [[model.dict objectForKey:@"member"] objectForKey:@"phone"]];
        if (![[[model.dict objectForKey:@"member"] objectForKey:@"sex"] isEqual:[NSNull null]]) {
            
            if ([[[model.dict objectForKey:@"member"] objectForKey:@"sex"]isEqualToString:@"男"]) {
                self.sexImage.image=[UIImage imageNamed:@"nan"];
                
                
            }else{
                self.sexImage.image=[UIImage imageNamed:@"nv"];
            }
        }else{
            self.sexImage.image=[UIImage imageNamed:@"nv"];
            
            
        }
        
        
        
//        if ([[NSString stringWithFormat:@"%@",[[model.dict objectForKey:@"member"] objectForKey:@"gradeName"]] isEqualToString:@"金"]) {
            _levelLabel.text=[Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"member"] objectForKey:@"gradeName"]]];
            _levelLabel.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
//        }
        if ([[NSString stringWithFormat:@"%@", [Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"member"] objectForKey:@"gradeName"]]]] isEqualToString:@"银"]) {
            _levelLabel.text=@"银";
            _levelLabel.backgroundColor=[UIColor colorWithRed:175/255.0 green:175/255.0 blue:175/255.0 alpha:1.0];
        }
        if ([[NSString stringWithFormat:@"%@", [Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"member"] objectForKey:@"gradeName"]]]] isEqualToString:@"铜"]) {
            _levelLabel.text=@"铜";
            _levelLabel.backgroundColor=[UIColor colorWithRed:126/255.0 green:56/255.0 blue:39/255.0 alpha:1.0];
        }


    }

    if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"deliveryType"]]isEqualToString:@"shsm"]) {
        self.consigneeLabel.text=[NSString stringWithFormat:@"%@(%@)", [[model.dict objectForKey:@"send"] objectForKey:@"consignee"],[[model.dict objectForKey:@"send"] objectForKey:@"phone"]];
        self.sendLabel.text= [NSString stringWithFormat:@"%@",@"快递配送"];
        self.freightLabel.text= [NSString stringWithFormat:@"¥ %@", [[model.dict objectForKey:@"order"] objectForKey:@"expressFee"]];
        self.addressLabel.text=[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"send"] objectForKey:@"address"]];
     
        
    }else{
        
                self.sendLabel.text= [NSString stringWithFormat:@"%@",@"到店自提"];
                self.freight.text= [NSString stringWithFormat:@"%@",@"提货日期"];
        
                NSString* string =[[model.dict objectForKey:@"delivery"] objectForKey:@"takeDate"] ;

               self.freightLabel.text= [NSString stringWithFormat:@"%@", string];
               self.consignee.text= [NSString stringWithFormat:@"%@",@"提货门店"];
               self.consigneeLabel.text= [NSString stringWithFormat:@"%@", [[model.dict objectForKey:@"delivery"] objectForKey:@"companyName"]];               self.address.text= [NSString stringWithFormat:@"%@",@"门店地址"];
               self.addressLabel.text=[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"delivery"] objectForKey:@"address"]];
        
        if ([[NSString stringWithFormat:@"%@",  [[model.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
        
        
            self.takeExpiryDate.text= [NSString stringWithFormat:@"%@",@"提货有效期"];
        
            NSString* string =[[model.dict objectForKey:@"order"] objectForKey:@"takeExpiryDate"] ;
            
            self.takeExpiryDateLabel.text= [NSString stringWithFormat:@"%@", string];
        }
    }
    orderItemArray=[model.dict objectForKey:@"orderItem"];
    if (orderItemArray.count>0) {
        for (int i = 0; i<orderItemArray.count; i++) {
            goodsView = [[GoodsView alloc]initWithFrame:CGRectMake(0, hight1+45, ScreenWidth, 1)];
            goodsView.backgroundColor=[UIColor whiteColor];

        }
        _heightView.frame=CGRectMake(0, goodsView.bottom, ScreenWidth, 0.15);
        UILabel* totalQuantity=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-250, 0, 235, 45)];
        totalQuantity.text=[NSString  stringWithFormat:@"共 %@ 件",[[model.dict objectForKey:@"order"]objectForKey:@"totalQuantity"]];
        totalQuantity.textColor = zhonghuiColor;
        totalQuantity.textAlignment = NSTextAlignmentRight;
        totalQuantity.font = [UIFont systemFontOfSize:14];
        [_orderItemView addSubview:totalQuantity];
        }else{
            
            UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-120, 0, 105, 44)];
            shangpingxinxi.text=@"自定义商品";
            shangpingxinxi.textColor=shenhuiColor;
            shangpingxinxi.textAlignment=NSTextAlignmentRight;
            shangpingxinxi.font=[UIFont systemFontOfSize:15];
            [_orderItemView addSubview:shangpingxinxi];

           _heightView.frame=CGRectMake(0, hight1+45, ScreenWidth, 0.15);
       
        }
}



-(void)setDeliveryModel:(DeliveryDetailModel *)DeliveryModel{
    if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"deliveryType"]]isEqualToString:@"shsm"]) {
        hight1=310;
    }else{
        if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
            hight1=330;
            
        }else{
            
            hight1=310;
        }
        
    }

    [self initUI];
    [self setViewAutoLayout:DeliveryModel.dict];
 
    _orderDateLabel.text=[NSString stringWithFormat:@"下单时间"];
    self.orderNoLabel.text=[NSString stringWithFormat:@"%@", [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"orderNo"]];
    
    
    if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"deliveryStatus"]] isEqualToString:@"Y"]) {
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=luseColor;
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.text=[NSString stringWithFormat:@"%@", @"零售 "];
    }else{
        self.stateLabel.font=[UIFont systemFontOfSize:11];
        self.stateLabel.textColor=[UIColor whiteColor];
        self.stateLabel.backgroundColor=orangeCol;
        self.stateLabel.text=[NSString stringWithFormat:@"%@", @"预售 "];
    }
    
    if ([[NSString stringWithFormat:@"%@",   [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"payStatusName"]]isEqualToString:@"已收银"]) {
        self.stateLabel1.textColor=luseColor;
    }else{
        self.stateLabel1.textColor=shenhongseColor;
    }
    if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]]isEqualToString:@"已完成"]) {
        self.stateLabel2.textColor=luseColor;
    }else if([[NSString stringWithFormat:@"%@", [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]]isEqualToString:@"已取消"]){
        self.stateLabel2.textColor=shenhuiColor;
        
    }else{
        self.stateLabel2.textColor=shenhongseColor;
        
    }
    
    self.stateLabel1.text=[NSString stringWithFormat:@"%@",   [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"payStatusName"]];
    self.stateLabel2.text=[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"orderStatusName"]];
    self.sourceLabel.text=[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"source"]];
   
    NSString* string =[[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"orderDate"] ;
    self.orderDate.text=[NSString stringWithFormat:@"%@",   string];
    
    NSDictionary *value = [DeliveryModel.dict objectForKey:@"member"];
    NSLog(@"---%ld",value.count);
    
       [_jiantouBtn removeFromSuperview];
    if (value.count==0)
    {
        self.memberName.text=@"零售会员";
        self.sexImage.image=[UIImage imageNamed:@""];
        _level.text=@"";
        _levelLabel.backgroundColor=[UIColor clearColor];
        _levelLabel.text=@"";
        [_jiantouBtn removeFromSuperview];
        
    }
    else
    {
        self.memberName.text=[NSString stringWithFormat:@"%@ (%@)",[[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"memberName"], [[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"phone"]];
        if (![[[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"sex"] isEqual:[NSNull null]]) {
            
            if ([[[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"sex"]isEqualToString:@"男"]) {
                self.sexImage.image=[UIImage imageNamed:@"nan"];
                
                
            }else{
                self.sexImage.image=[UIImage imageNamed:@"nv"];
            }
        }else{
            self.sexImage.image=[UIImage imageNamed:@"nv"];
            
            
        }
        
        
        
        //        if ([[NSString stringWithFormat:@"%@",[[model.dict objectForKey:@"member"] objectForKey:@"gradeName"]] isEqualToString:@"金"]) {
        _levelLabel.text=[Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"gradeName"]]];
        _levelLabel.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
        //        }
        if ([[NSString stringWithFormat:@"%@", [Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"gradeName"]]]] isEqualToString:@"银"]) {
            _levelLabel.text=@"银";
            _levelLabel.backgroundColor=[UIColor colorWithRed:175/255.0 green:175/255.0 blue:175/255.0 alpha:1.0];
        }
        if ([[NSString stringWithFormat:@"%@", [Global getJudgeTheErrorStr: [NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"member"] objectForKey:@"gradeName"]]]] isEqualToString:@"铜"]) {
            _levelLabel.text=@"铜";
            _levelLabel.backgroundColor=[UIColor colorWithRed:126/255.0 green:56/255.0 blue:39/255.0 alpha:1.0];
        }
        
        
    }
    
    if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"deliveryType"]]isEqualToString:@"shsm"]) {
        self.consigneeLabel.text=[NSString stringWithFormat:@"%@(%@)", [[DeliveryModel.dict objectForKey:@"send"] objectForKey:@"consignee"],[[DeliveryModel.dict objectForKey:@"send"] objectForKey:@"phone"]];
        self.sendLabel.text= [NSString stringWithFormat:@"%@",@"快递配送"];
        self.freightLabel.text= [NSString stringWithFormat:@"¥ %@", [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"expressFee"]];
        self.addressLabel.text=[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"send"] objectForKey:@"address"]];
        
        
    }else{
        
        self.sendLabel.text= [NSString stringWithFormat:@"%@",@"到店自提"];
        self.freight.text= [NSString stringWithFormat:@"%@",@"提货日期"];
       
        NSString* string =[[DeliveryModel.dict objectForKey:@"delivery"] objectForKey:@"takeDate"] ;
        
        self.freightLabel.text= [NSString stringWithFormat:@"%@", string];
        self.consignee.text= [NSString stringWithFormat:@"%@",@"提货门店"];
        self.consigneeLabel.text= [NSString stringWithFormat:@"%@", [[DeliveryModel.dict objectForKey:@"delivery"] objectForKey:@"companyName"]];               self.address.text= [NSString stringWithFormat:@"%@",@"门店地址"];
        self.addressLabel.text=[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"delivery"] objectForKey:@"address"]];
        
        if ([[NSString stringWithFormat:@"%@",  [[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
            
            
            self.takeExpiryDate.text= [NSString stringWithFormat:@"%@",@"提货有效期"];
            
            NSString* string =[[DeliveryModel.dict objectForKey:@"order"] objectForKey:@"takeExpiryDate"] ;
            
            self.takeExpiryDateLabel.text= [NSString stringWithFormat:@"%@", string];
        }

    }
    
    orderItemArray=[DeliveryModel.dict objectForKey:@"orderItem"];
    if (orderItemArray.count>0) {
        UILabel* totalQuantity=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-200, 0, 185, 45)];
        totalQuantity.text=[NSString stringWithFormat:@"共 %ld 件",orderItemArray.count];
        totalQuantity.textColor=zhonghuiColor;
        totalQuantity.textAlignment=NSTextAlignmentRight;
        totalQuantity.font=[UIFont systemFontOfSize:13];
        [_orderItemView addSubview:totalQuantity];
        for (int i = 0; i<orderItemArray.count; i++) {
            goodsView = [[GoodsView alloc]initWithFrame:CGRectMake(0, hight1+45, ScreenWidth, 1)];
            goodsView.backgroundColor=[UIColor whiteColor];
            
        }
        _heightView.frame=CGRectMake(0, goodsView.bottom, ScreenWidth, 0.15);
    }else{
        
        UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-120, 0, 105, 44)];
        shangpingxinxi.text=@"自定义商品";
        shangpingxinxi.textColor=shenhuiColor;
        shangpingxinxi.textAlignment=NSTextAlignmentRight;
        shangpingxinxi.font=[UIFont systemFontOfSize:15];
        [_orderItemView addSubview:shangpingxinxi];
        
        _heightView.frame=CGRectMake(0, hight1+45, ScreenWidth, 0.15);
        
    }
    
       [_jiantouBtn removeFromSuperview];
}

-(void)setViewAutoLayout:(NSDictionary*)dict
{
    [self.orderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0) ;
        make.height.equalTo(@420);
        make.top.equalTo(self.mas_top).with.offset(0);
    }];
    [self.orderNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@17);
        make.top.equalTo(self.mas_top).with.offset(15);
    }];
    [self.noView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0) ;
        make.height.equalTo(@70);
        make.top.equalTo(self.mas_top).with.offset(0);
    }];
    [self.memberView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0) ;
        make.height.equalTo(@45);
        make.top.equalTo(self.noView.mas_bottom).with.offset(10);
    }];
   
    [self.sendView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0) ;
        make.height.equalTo(@165);
        make.top.equalTo(self.memberView.mas_bottom).with.offset(10);
    }];

    
    [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderNoLabel.mas_right).with.offset(7.5);
        make.height.equalTo(@13);
        
        make.centerY.equalTo(self.orderNoLabel.mas_centerY) ;
    }];
    [self.stateLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.stateLabel.mas_right).with.offset(5);
        make.height.equalTo(@13);
        
         make.centerY.equalTo(self.orderNoLabel.mas_centerY) ;
    }];
    [self.stateLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.stateLabel1.mas_right).with.offset(5);
        make.height.equalTo(@13);
        
          make.centerY.equalTo(self.orderNoLabel.mas_centerY) ;
    }];
    
    [self.source mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.orderNoLabel.mas_bottom).with.offset(10);
    }];

    [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.source.mas_right).with.offset(3);
        make.height.equalTo(@14);
        make.top.equalTo(self.orderNoLabel.mas_bottom).with.offset(10);
    }];

    [self.orderDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.sourceLabel.mas_right).with.offset(15) ;
        make.height.equalTo(@14);
        make.centerY.equalTo(self.source.mas_centerY) ;
    }];
    [self.orderDate mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.orderDateLabel.mas_right).with.offset(3) ;
        make.height.equalTo(@14);
        make.centerY.equalTo(self.source.mas_centerY) ;
    }];

    [self.memberName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@45);
        make.top.equalTo(self.noView.mas_bottom).with.offset(10);
        
    }];
    [self.sexImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.memberName.mas_right).with.offset(3);
        make.height.equalTo(@20);
        make.width.equalTo(@20);
        make.centerY.equalTo(self.memberName.mas_centerY) ;
    }];
    
    [self.level mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.sexImage.mas_right).with.offset(15);
        make.height.equalTo(@14);
        make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
    [self.levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.level.mas_right).with.offset(3);
        make.height.equalTo(@14);
//        make.width.equalTo(@14);
        make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
    [self.jiantouBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-5) ;
        make.height.equalTo(@33);
        make.width.equalTo(@33);
        make.centerY.equalTo(self.memberName.mas_centerY) ;
        
    }];
   
    [self.sendInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@45);
        make.top.equalTo(self.mas_top).with.offset(135);
    }];
    
    [self.send mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15);
        make.height.equalTo(@14);
        make.top.equalTo(self.sendInfo.mas_bottom).with.offset(7);
        
    }];
    
    [self.sendLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-15) ;
        make.height.equalTo(@14);
        make.centerY.equalTo(self.send.mas_centerY) ;
        
    }];
    
    [self.freight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15);
        make.height.equalTo(@14);
        make.top.equalTo(self.send.mas_bottom).with.offset(7);
        
    }];
    
    
    
    [self.freightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-15) ;
        make.height.equalTo(@14);
        make.centerY.equalTo(self.freight.mas_centerY) ;
        
    }];
    
    
    
    if ([[NSString stringWithFormat:@"%@",  [[dict objectForKey:@"order"] objectForKey:@"deliveryType"]]isEqualToString:@"shsm"]) {
        
        [self.consignee mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(15) ;
            make.height.equalTo(@14);
            make.top.equalTo(self.freight.mas_bottom).with.offset(7);
        }];
        
        [self.consigneeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_right).with.offset(-15) ;
            make.height.equalTo(@14);
            make.centerY.equalTo(self.consignee.mas_centerY) ;
            
        }];

    }else{
       

        
        if ([[NSString stringWithFormat:@"%@",  [[dict objectForKey:@"order"] objectForKey:@"docType"]] isEqualToString:@"Booking"]) {
            
            [self.takeExpiryDate mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.mas_left).with.offset(15);
                make.height.equalTo(@14);
                make.top.equalTo(self.freight.mas_bottom).with.offset(7);
                
            }];
            [self.takeExpiryDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.mas_right).with.offset(-15) ;
                make.height.equalTo(@14);
                make.centerY.equalTo(self.takeExpiryDate.mas_centerY) ;
                
            }];

            [self.consignee mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.mas_left).with.offset(15) ;
                make.height.equalTo(@14);
                make.top.equalTo(self.takeExpiryDate.mas_bottom).with.offset(7);
            }];
            
            [self.consigneeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.mas_right).with.offset(-15) ;
                make.height.equalTo(@14);
                make.centerY.equalTo(self.consignee.mas_centerY) ;
                
            }];

        }else{
        
            [self.consignee mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.mas_left).with.offset(15) ;
                make.height.equalTo(@14);
                make.top.equalTo(self.freight.mas_bottom).with.offset(7);
            }];
            
            [self.consigneeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.mas_right).with.offset(-15) ;
                make.height.equalTo(@14);
                make.centerY.equalTo(self.consignee.mas_centerY) ;
                
            }];

        }
        
    }

       [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(15) ;
        make.height.equalTo(@14);
        make.top.equalTo(self.consignee.mas_bottom).with.offset(7);
    }];
    
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.address.mas_right).with.offset(15) ;
        make.right.equalTo(self.mas_right).with.offset(-15) ;

       make.top.equalTo(self.consignee.mas_bottom).with.offset(7);
        
    }];
    [self.orderItemView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0);
        make.height.equalTo(@45);
       make.top.equalTo(self.mas_top).with.offset(hight1);
    }];
    
    
}

@end
